<?php
    /* 个人资料页 可修改个人资料
     * @判断session， 得到uId，获得数据表的用户信息 getUserId
     * 
     * 为解决问题：浏览器对图片缓存，更换图片后，图片名字路径一致，需刷新才能看到更新的图片
     *  */

    require_once 'header.php';
    require_once '../inc/user.php';
    /* error_reporting(0); */
?>
<!DOCTYPE HTML>
<html>
	<head>
		<title>个人资料页-阅读记</title>
		<!-- <meta http-equiv="refresh" content="20"> -->
		<meta charset="UTF-8">
		<meta http-equiv="Expires" CONTENT="0">
		<link rel="stylesheet" href="../css/perDocument.css">
		<script type="text/javascript" src=../inc/jquery-2.1.1.min.js></script>
		<script type="text/javascript" src=../script/perDocument.js></script>
 
	</head>
	<body >
	<?php 
	   if (isset($_SESSION["CURRENT_USER"])) {
	       $current_user=$_SESSION["CURRENT_USER"];
	       $uId=$current_user["uId"];
	       $curUser=getUserId($uId);
	       /* var_dump($curUser); */
	       $head=$curUser["head"];
	       $userRegtime=($curUser["regtime"]);
	       $topicRegtime=time();
	       $reg=date("Y-m-d",time());
	   }
	?>
		<div class="main">
			<div class="document">
				<div class="Doctitle"><span>编辑资料</span></div>
				<form  name="headForm" id="headForm" action="../admin/upload.php" method="post" enctype="multipart/form-data" target="shangchuan">
					<input name="uId" type="hidden" value="<?php echo $curUser["uId"]?>" id="uId"/>
					<input type="hidden" name="pic" value=""  id="pic" />
					
                            <div id="preview" style="background:url(../image/head/<?php echo $head;?>); background-size:100% 100%"  >
                                <input type="file" id="file" name="file" title="点击更换头像，如果头像未更新，请刷新试试" onchange="document.getElementById('headForm').submit()"> 
					       </div>
					<div class="tr">
							<span>ID：<?php echo $curUser['uId']; ?></span><br>
							<span>注册时间：<?php echo $reg; ?></span>
					</div>	
				</form>
				<iframe style="display:none" name="shangchuan" id="shangchuan">
				</iframe>
				
				
				
				<form name="docForm"  id="docForm" action="../admin/doPerdocment.php" method="post" onsubmit="return checkForm()" enctype="multipart/form-data">
					 <input name="uId" type="hidden" value="<?php echo $curUser["uId"]?>" id="uId"/>
					<fieldset class="accountFiled">
						<legend>&emsp;账号信息&emsp;</legend>
						<div class="tr">
								<div class="spanAccount"><span>用户名</span></div>
								<div><input type="text" name="uName" id="uName" value="<?php echo $curUser["uName"]?>" style="float:left;" oninput="nameCheck()" placeholder="用户名不能为空"></div>
								<div id="uNameDete"><p><?php echo ""; ?></p></div>
								
						</div><br>
						<div class="tr">
								<div class="spanAccount"><span>邮箱</span></div>
								<div class="inp"><input type="email" name="email" id="email" value="<?php echo $curUser["email"]?>" placeholder="邮箱不能为空"/></div>
						</div><br>
						<div class="tr">
								<div class="spanAccount"><span>密码</span></div>
								<div class="inp"><input type="password" name="uPass" id="uPass" oninput="passCheck()" value="<?php echo $curUser["uPass"]?>" placeholder="密码不能为空"/></div>
						</div><br>
						<div  id="tr">
								<span><?php echo "";?></span>
						</div><br>
					</fieldset>
					<fieldset class="moreFiled">
						<legend>&emsp;详细信息&emsp;</legend>
							<div class="tr">
								<div class="spanAccount"><span>性别</span></div>
								<div class="gender">
								<?php 
								$sex=$curUser["sex"];
								$man="男";
								$woman="女";
								$serect="保密";
								$sexshow="";
								if(hash_equals($sex,$man)){
								    $sexshow.=<<<sex
   				         <label class="sex">男&emsp;<input type="radio" value="男" name="sex" checked/></label>
   				         <label class="sex">女&emsp;<input type="radio" value="女" name="sex" /></label>
   				         <label class="sex">保密&emsp;<input type="radio" value="保密" name="sex""/></label>
sex;
								}
								else if(hash_equals($sex, $woman)){
								    $sexshow.=<<<sex
   				         <label class="sex">男&emsp;<input type="radio" value="男" name="sex" /></label>
   				         <label class="sex">女&emsp;<input type="radio" value="女" name="sex" checked/></label>
   				         <label class="sex">保密&emsp;<input type="radio" value="保密" name="sex"/></label>
sex;
								    
								}
								else{
								    $sexshow.=<<<sex
   				         <label class="sex" >男&nbsp;<input type="radio" value="男" name="sex" /></label>
   				         <label class="sex" >女&nbsp;<input type="radio" value="女" name="sex" /></label>
   				         <label class="sex" >保密&nbsp;<input type="radio" value="保密" name="sex" checked/></label>
sex;
								}
								echo $sexshow;
								?>
								</div><br><!-- /gender -->
							</div><!-- /tr -->
							<div class="tr" >
								<div class="spanAccount"><span>生日</span></div>
								<?php 
								$birthshow="";
								      if (isset($curUser["birthday"]))
								      {
								          $birthday=$curUser["birthday"];
								          $birthshow.=<<<html
                                                <input type="text"  name="birthday" class="bir" value="$birthday" placeholder="Eg: 2020-1-1" />
html;
								      }
								          else 
								          {
								              $birthshow.=<<<html
								              <input type="text"   name="birthday" class="bir" placeholder="Eg: 2020-1-1">
html;
								          }
								              echo $birthshow;
								?>
							</div><br>
							<div class="tr" >
								<div class="spanAccount"><span>喜欢的书</span></div>
								<?php 
								$bookshow="";
								      if (isset($curUser["birthday"]))
								      {
								          $book=$curUser["book"];
								          $bookshow.=<<<html
                                                <textarea rows="2" class="book" name="book" maxLength="50">$book</textarea>
html;
								      }
								          else
								          {
								              $bookshow.=<<<html
								              <textarea rows="2"  class="book" name="book" maxLength="50"></textarea>
html;
								          }
								              echo $bookshow;
								?>
							</div><br><!-- /book -->
							<div class="tr" >
								<div class="spanAccount"><span>喜欢的电影</span></div>
								<?php 
								$movieshow="";
								      if (isset($curUser["movie"])) 
								      {
								          $movie=$curUser["movie"];
								          $movieshow.=<<<html
								          <textarea rows="2" class="movie" name="movie" maxLength="50">$movie</textarea>
html;
								      }
								          else
								          {
								              $movieshow.=<<<html
								              <textarea rows="2"  class="movie" name="movie" maxLength="50"></textarea>
html;
								          }
								          echo $movieshow;
								?>
							</div><br><!-- /movie -->
							<div class="tr" >
								<div class="spanAccount"><span>个人说明</span></div>
								<?php 
								$statementshow="";
								      if (isset($curUser["statement"]))
								      {
								          $statement=$curUser["statement"];
								          $statementshow.=<<<html
								          <textarea rows="2" class="statement" name="statement" maxLength="100">$statement</textarea>
html;
								      }
								          else
								          {
								              $statementshow.=<<<html
								              <textarea rows="2"  class="statement" name="statement" maxLength="100"></textarea>
html;
								          }
								          echo $statementshow;
								?>
							</div><br><!-- /statement -->						
							
					</fieldset>
					
					<div class="subBtn">
						<input type="submit" value="提交修改" id="sub" onclick="return checkFrom()">
						<input type="reset" value="重置信息" onclick="reset()" >
					</div>
				</form>
				
			</div>
		</div>
		<?php require_once 'footer.php';?>
	</body>
</html>